package com.common;

import java.util.concurrent.atomic.AtomicInteger;

import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;

public class ViewPageHandler extends Handler {

	public AtomicInteger what = new AtomicInteger(0);
	public ViewPager viewPager;
	public int totalpage=0;
	public int delayedTime=2000;
 	public ViewPageHandler(ViewPager _viewPager,int _totalpage)
	{
		viewPager=_viewPager;	
		totalpage=_totalpage;
	}
	
	@Override
	public void handleMessage(Message msg) {
		
		int num = what.incrementAndGet();
		
		if(num<totalpage)
		{
			    viewPager.setCurrentItem(num); 
		}  
		else { 
				what.set(0);
				viewPager.setCurrentItem(0);				
		}
		
		super.handleMessage(msg);
		
	}
	
}
